package com.niit.apis;

import com.niit.entity.Job;
import com.niit.entity.User;
import jakarta.servlet.http.HttpSession;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(name = "job-service")
public interface JobFeignApi {

    //发布职位
    @PostMapping("/api/job/add")
     void addJob(@RequestBody Job job);

    //修改职位信息
    @PutMapping("/api/job/update")
     void updateJob(@RequestBody Job job);

    //删除职位信息
    @DeleteMapping("/api/job/delete/{id}")
     void deleteJob(@PathVariable("id") Integer id);

    //获取职位信息
    @GetMapping("/api/job/get/{id}")
     Job getJob(@PathVariable("id") Integer id);

    //获取所有职位信息
    @GetMapping("/api/job/getAll")
    List<Job> getAllJobs();

    //获取个人发布的职位信息
    @PostMapping("/api/job/getJobs")
     List<Job> getMyJobs(@RequestBody User user);

    //获取个人发布的职位数量
    @GetMapping("/api/job/getJobCount")
     Integer getJobCount(@RequestBody User user);

    //搜索职位信息
    @GetMapping("/api/job/search")
     List<Job> searchJob(String keyword);

    // 多条件分页查询
    @GetMapping("/api/job/page")
    Page<Job> getJobsByCondition(
            @RequestParam(value = "title", required = false) String title,
            @RequestParam(value = "publishUser", required = false) String publishUser,
            @RequestParam(value = "status", required = false) Byte status,
            @RequestParam(value = "page", defaultValue = "1") int page,
            @RequestParam(value = "limit", defaultValue = "10") int limit);

    @PutMapping("/api/job/audit")
     void auditJob(@RequestParam("id") Integer id, @RequestParam("status") Byte status);


    @GetMapping("/api/job/auditedJobs")
     List<Job> getAuditedJobs();

    @GetMapping("/api/job/condition")
    Page<Job> searchJobByCondition(
            @RequestParam(required = false) String location,
            @RequestParam(required = false) String salaryRange,
            @RequestParam(required = false) String keyword,
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "10") int size);

}
